package it.koutifaris.travianmap.model.impl;

import it.koutifaris.travianmap.model.Alliance;
import it.koutifaris.travianmap.model.Player;
import it.koutifaris.travianmap.model.Tribe;
import it.koutifaris.travianmap.model.Village;

import java.util.List;

public class PlayerImpl extends AbstractDomainObject implements Player {

	private final String name;
	private final Alliance alliance;
	private final Tribe tribe;
	private final VillagesLoader villagesLoader;
	private List<Village> villages;

	public PlayerImpl(int id, String name, Tribe tribe, Alliance alliance, VillagesLoader villagesLoader) {
		super(id);
		this.name = name;
		this.tribe = tribe;
		this.alliance = alliance;
		this.villagesLoader = villagesLoader;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public Alliance getAlliance() {
		return alliance;
	}

	@Override
	public Tribe getTribe() {
		return tribe;
	}

	@Override
	public List<Village> getVillages() {
		if (villages == null) {
			villages = villagesLoader.getVillages();
		}

		return villages;
	}

}
